#include "mastermindgame.h"

MastermindGame::MastermindGame(QObject *parent) :
    QObject(parent)
{
    randomseed = qrand();
    qsrand(randomseed);
}

int MastermindGame::pickColors()
{
    for (int t; t < 4; t++) {
        randomseed = t + 4 + qrand() + randomseed;
        qsrand(randomseed);
        colors[t] = qrand() % 7;
    }
    return 0;
}

int MastermindGame::compareGuess(int g[4], int r[4])
{
    // Return 0 - black peg 1 - white peg
    // in r

    // Nested for's...
    for (int i; i < 4; i++) {
        for (int z; z < 4; z++) {
            if (g[i] == colors[i]) {
                // Black peg
                r[i] = 0;
            } else {
                if (g[i] == colors[z]) {
                    // White peg
                    r[i] = 1;
                }
            }
        }
    }
    return 0;
}
